import request from '@/utils/request'

// 创建订单
export function createOrderApi(data) {
  return request({
    url: '/order/create',
    method: 'post',
    data
  })
}

// 获取订单支付金额和截止时间
export function getOrderDetailsApi(id) {
  return request.get(`/order/payDetails/${id}`)
}

// 获取用户订单列表
export function getOrderListApi(orderStatus) {
  return request.get(`/order/list?orderStatus=${orderStatus}`)
}

// 模拟支付
export function paySubmitApi(id) {
  return request({
    url: `/order/paySuccess/${id}`,
    method: 'put'
  })
}

// 取消订单
export function cancelOrderApi(id) {
  return request({
    url: `/order/cancelOrder/${id}`,
    method: 'put'
  })
}

// 获取订单详情
export function getDetailsApi(id) {
  return request({
    url: `/order/details/${id}`
  })
}

// 完成订单
export function finishOrderApi(id) {
  return request({
    url: `/order/finish/${id}`,
    method: 'put'
  })
}

// 退款
export function refundOrderApi(id) {
  return request({
    url: `/order/refund/${id}`,
    method: 'put'
  })
}

// 取消退款
export function cancelRefundOrderApi(id) {
  return request({
    url: `/order/cancelRefund/${id}`,
    method: 'put'
  })
}

// 同意退款
export function agreeRefundOrderApi(id) {
  return request({
    url: `/order/agreeRefund/${id}`,
    method: 'put'
  })
}

// 删除订单
export function deleteOrderApi(id) {
  return request({
    url: `/order/delete/${id}`,
    method: 'delete'
  })
}

// 查看我卖出的订单列表
export function mySellListApi(orderStatus) {
  return request(`/order/mySell?orderStatus=${orderStatus}`)
}
